package com.jnc.web.biz.tool.model;

import com.jnc.common.base.BaseReq;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.util.Date;
import java.util.List;

/**
 * @Author: jjn
 * @Date: 2018/11/14
 * @Desc: 数据库表信息
 */
public class TableInfo extends BaseReq {
    private static final long serialVersionUID = 1L;

    private String tableName;               //表名称
    private String tableComment;            //表注释
    private ColumnInfo primaryKey;          //表主键列信息
    private List<ColumnInfo> columns;       //表的列名(不包含主键)
    private String className;               //类名(第一个字母大写)
    private String classname;               //类名(第一个字母小写)
    private Date createTime;
    private Date updateTime;

    public String getTableName() {
        return tableName;
    }

    public void setTableName(String tableName) {
        this.tableName = tableName;
    }

    public String getTableComment() {
        return tableComment;
    }

    public void setTableComment(String tableComment) {
        this.tableComment = tableComment;
    }

    public ColumnInfo getPrimaryKey() {
        return primaryKey;
    }

    public void setPrimaryKey(ColumnInfo primaryKey) {
        this.primaryKey = primaryKey;
    }

    public List<ColumnInfo> getColumns() {
        return columns;
    }

    public void setColumns(List<ColumnInfo> columns) {
        this.columns = columns;
    }

    public String getClassName() {
        return className;
    }

    public void setClassName(String className) {
        this.className = className;
    }

    public String getClassname() {
        return classname;
    }

    public void setClassname(String classname) {
        this.classname = classname;
    }

    /**
     * 获取主键
     * @return
     */
    public ColumnInfo getColumnsLast(){
        ColumnInfo columnInfo = null;
        if(this.columns != null && this.columns.size() > 0){
            columnInfo = this.columns.get(0);
        }
        return columnInfo;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this)
                .append("tableName", tableName)
                .append("tableComment", tableComment)
                .append("primaryKey", primaryKey)
                .append("columns", columns)
                .append("className", className)
                .append("classname", classname)
                .append("updateTime", updateTime)
                .append("createTime", createTime)
                .toString();
    }
}
